package com.mayikt.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @ClassName MayiktCallable
 * @Author 蚂蚁课堂余胜军 QQ644064779 www.mayikt.com
 * @Version V1.0
 **/
public class MayiktCallable implements Callable<String> {
    @Override
    public String call() throws Exception {
        System.out.println(Thread.currentThread().getName() + ",开始异步发送短信");
        try {
            Thread.sleep(3000);
        } catch (Exception e) {

        }
        return "异步发送短信成功";
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MayiktCallable mayiktCallable = new MayiktCallable();
        FutureTask<String> futureTask = new FutureTask<>(mayiktCallable);
        new Thread(futureTask).start();
        System.out.println(futureTask.get());
    }
}
